package com.cn.zengzeng.spbzengzeng.singleton.dto4;

/**
 * 枚举单例模式  线程安全
 * @Author: ZhangZengZeng
 * @Date: 2023/3/18 15:59
 */
public class SingletonDemo {

    private SingletonDemo(){
    }

    public static SingletonDemo getInstance(){
        return InnerEnum.INNER_ENUM.getInstance();
    }
    private static enum InnerEnum {
        INNER_ENUM;

        private final SingletonDemo singletonDemo ;

        private InnerEnum(){
            singletonDemo = new SingletonDemo() ;
        }
        private SingletonDemo getInstance(){
             return singletonDemo;
        }
    }
}
